"""用户认证模块的URL路由配置

定义用户认证相关的API路由。
"""

from django.urls import path, include
from rest_framework.routers import DefaultRouter
from rest_framework_simplejwt.views import TokenRefreshView

from .views import (
    AuthViewSet,
    CustomTokenObtainPairView,
    UserViewSet,
    UserProfileViewSet
)

# 创建路由器
router = DefaultRouter()
router.register(r'auth', AuthViewSet, basename='auth')
router.register(r'users', UserViewSet, basename='user')
router.register(r'profile', UserProfileViewSet, basename='profile')

app_name = 'authentication'

urlpatterns = [
    # JWT Token相关路由
    path('auth/login/', CustomTokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    
    # 包含路由器生成的URL
    path('', include(router.urls)),
]

# API路由说明：
# POST /api/v1/auth/register/          - 用户注册
# POST /api/v1/auth/login/             - 用户登录
# POST /api/v1/auth/refresh/           - 刷新Token
# POST /api/v1/auth/logout/            - 用户登出
# 
# GET  /api/v1/users/me/               - 获取当前用户信息
# PUT  /api/v1/users/update_profile/   - 更新用户信息
# POST /api/v1/users/change_password/  - 修改密码
# GET  /api/v1/users/login_history/    - 获取登录历史
# 
# GET  /api/v1/profile/me/             - 获取用户配置
# PUT  /api/v1/profile/update_config/  - 更新用户配置